// login module
import { makeAutoObservable } from 'mobx';
import { http, setToken, getToken, removeToken } from '../utils';
class LoginStore {
  token = getToken() || '';
  constructor() {
    makeAutoObservable(this);
  }
  getToken = async ({ mobile, code }) => {
    // 调用登录接口
    const res = await http.post('http://127.0.0.1:4523/m1/1316691-0-default/data', { mobile, code });
    // 存入token
    this.token = res.data.token;
    setToken(this.token);
  };

  loginOut = () => {
    this.token = '';
    removeToken();
  };
}
export default LoginStore;
